package com.jingdianjichi.auth.entity;

import lombok.Getter;

@Getter
public enum ResultCodeEnum {

    SUCCESS(200,"成功"),
    FAIL(500,"失败");

    //状态码
    private int code;

    //枚举的描述
    private String desc;

    ResultCodeEnum(int code,String desc){
        this.code=code;
        this.desc=desc;
    }

    //根据值获得枚举
    public static ResultCodeEnum getByCode(int codeVal){
        for (ResultCodeEnum resultCodeEnum:ResultCodeEnum.values()){
            if (resultCodeEnum.code == codeVal){
                return resultCodeEnum;
            }
        }

        return null;
    }
}
